﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;

namespace SpotiKat.Spotify.Manager
{
    public class LogManager
    {
        public static LogManager Instance
        {
            get { return new LogManager(); }
        }

        public void LogError(string message, Exception ex)
        {
            try
            {
                /*
                log4net.ILog Log = log4net.LogManager.GetLogger("RollingErrorLogFileAppender");
                if (Log.IsErrorEnabled)
                {
                    if (ex == null)
                    {
                        Log.Error(message);
                    }
                    else
                    {
                        Log.Error(message, ex);
                    }
                }*/

                using (StreamWriter sw = File.AppendText(@"D:\hshome\anderslind\spotikat.com\error.log"))
                {
                    sw.WriteLine(DateTime.Now + " - " + message + " - " + ex.Message + "\n" + ex.StackTrace);
                    sw.Close();
                }
            }
            catch (Exception e)
            {
            }
        }

        public void LogInfo(string message)
        {
            try
            {
                /*
                log4net.ILog Log = log4net.LogManager.GetLogger("RollingInfoLogFileAppender");
                if (Log.IsInfoEnabled)
                {
                    Log.Info(message);
                }*/

                using (StreamWriter sw = File.AppendText(@"D:\hshome\anderslind\spotikat.com\info.log"))
                {
                    sw.WriteLine(DateTime.Now + " - " + message);
                    sw.Close();
                }
            }
            catch (Exception e) 
            { 
            }
        }
    }
}
